package com.jk.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jk.po.ClentPO;
import com.jk.po.SharingPO;
import com.jk.vo.CustomerVO;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface SharingDao extends BaseMapper<SharingPO>{

    /**
    * @Author  郑滨
    * @method  querySharingRandom
    * @description 两条热度最高数据
    * @Date 19:37 2021/7/4
    * @Param  * @param
    * @return java.util.List<com.jk.po.SharingPO>
    **/
    @Select(value = "select * from travel_sharing s left join travel_customer c on s.customerid=c.id order by popularity desc LIMIT 0, 2")
    List<CustomerVO> querySharingRandom();
    /**
    * @Author  郑滨
    * @method  findByPopularity
    * @description 描述一下方法的作用
    * @Date 20:40 2021/7/4
    * @Param  * @param
    * @return java.util.List<com.jk.po.SharingPO>
    **/
    @Select(value="SELECT * FROM (SELECT * FROM travel_sharing ORDER BY RAND() LIMIT 7)a ORDER BY popularity DESC")
    List<SharingPO> findByPopularity();
    /**
    * @Author  郑滨
    * @method  querySharingList
    * @description 描述一下方法的作用
    * @Date 17:19 2021/7/5
    * @Param  * @param
    * @return java.util.List<com.jk.po.SharingPO>
    **/
    @Select(value = "select * from travel_sharing s left join travel_customer c on s.customerid=c.id")
    List<CustomerVO> querySharingList();


    /**
    * @Author  郑滨
    * @method  querySharingByID
    * @description 描述一下方法的作用
    * @Date 21:55 2021/7/5
    * @Param  * @param id
    * @return com.jk.vo.CustomerVO
    **/
    @Select(value = "select * from travel_sharing s left join travel_customer c on s.customerid=c.id where s.id=#{id}")
    CustomerVO querySharingByID(Integer id);
    /**
     *
     *
     * @param id
     * @author 赵磊荣
     * @date 2021/7/8 15:57
     * @return 查看用户个人发表的游记
     */
    @Select(value = "SELECT * FROM travel_sharing s left join travel_customer c ON s.customerid=c.id where c.id=#{id}")
    SharingPO querySharingListById(Integer id);

/**
 *
 *
 * @param id
 * @author 赵磊荣
 * @date 2021/7/8 16:32
 * @return 查看用户个人发表的游记
 */
    @Select(value = "SELECT * FROM travel_sharing s WHERE s.id=#{id}")
    List<SharingPO> querySharingListId(Integer id);
}
